/*

* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Smart-Shop开源商城系统/ Java商城-首选电商平台系统 请务必保留此注释头信息
* |     开源地址: https://gitee.com/ningbo-qishan/gruul-mall
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     可正常分享和学习源码,未经授权 不可商用！
* |     商业版中台购买/开源版商业授权 联系技术客服
* |     官网:  https://www.73app.cn/
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Copyright (c) 2016-2999 宁波启山智软科技有限公司
* |     版权所有 ,侵权必究！
* ------------------------------------------------------------------------

*/
package com.medusa.gruul.platform.web.controller.agent;


import cn.dev33.satoken.annotation.SaCheckLogin;
import com.medusa.gruul.common.core.annotation.EscapeLogin;
import com.medusa.gruul.common.core.util.PageUtils;
import com.medusa.gruul.common.core.util.Result;
import com.medusa.gruul.platform.model.vo.agent.AgentPackageOrdersVo;
import com.medusa.gruul.platform.model.vo.agent.AgentStatsVo;
import com.medusa.gruul.platform.service.IAgentInfoService;
import com.medusa.gruul.platform.service.IAgentPackageOrderService;
import com.medusa.gruul.platform.service.IAgentRechargeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author whh
 * @since 2020-11-06
 */
@RestController
@SaCheckLogin
@RequestMapping("/agent/console/packageOrder")
@Api(tags = "代理后台相关")
public class AgentPackageOrderController {

    @Autowired
    private IAgentInfoService agentInfoService;
    @Autowired
    private IAgentPackageOrderService agentPackageOrderService;


    @GetMapping("/stats")
    @EscapeLogin
    @ApiOperation(value = "分账数据统计", tags = "代理后台相关")
    public Result<AgentStatsVo> agentStats() {
        AgentStatsVo result = agentInfoService.agentStats();
        return Result.ok(result);
    }

    @GetMapping
    @EscapeLogin
    @ApiOperation(value = "分账数据列表", tags = "代理后台相关")
    public Result<PageUtils<AgentPackageOrdersVo>> packageOrders(@ApiParam(value = "指定页数", required = true) @RequestParam Integer page,
                                                                 @ApiParam(value = "数据条数", required = true) @RequestParam Integer size,
                                                                 @ApiParam(value = "开始时间") @RequestParam(required = false) String startTime,
                                                                 @ApiParam(value = "结束时间") @RequestParam(required = false) String endTime,
                                                                 @ApiParam(value = "订单号或者账号") @RequestParam(required = false) String search,
                                                                 @ApiParam(value = "支付方式") @RequestParam(required = false) String payType,
                                                                 @ApiParam(value = "订单状态") @RequestParam(required = false) Integer status
    ) {
        PageUtils<AgentPackageOrdersVo> result = agentPackageOrderService.packageOrders(page, size, startTime, endTime, search, payType, status);
        return Result.ok(result);
    }
}
